package com.nineclock.system.controller;

import com.nineclock.api.system.controller.SysUserControllerApi;
import com.nineclock.common.entity.Result;
import com.nineclock.dto.SysRegisterDTO;
import com.nineclock.dto.SysUserDTO;
import com.nineclock.system.service.SysUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
@Slf4j
public class SysUserController implements SysUserControllerApi {
    @Autowired
    private SysUserService sysUserService;
    @Override
    @GetMapping("/query")
    public Result<SysUserDTO> findUserInfo(@RequestParam("username") String username) {
        log.info("findUserInfo==??" + username);
        SysUserDTO userInfo = sysUserService.findUserInfo(username);
        log.info("根据用户名/手机号查询到的数据为:" + userInfo);
        return Result.success(userInfo);
    }

    // 注册用户
    @PostMapping("/register")
    @Override
    public Result<Long> registerUser( SysRegisterDTO sysRegisterDTO) {
        Long userId = sysUserService.register(sysRegisterDTO);
        return Result.success(userId);
    }
}
